package com.spleeb.pixelengine;

import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.view.Display;
import android.view.Window;
import android.view.WindowManager;

public class speng extends Activity implements SensorEventListener {
    /** Called when the activity is first created. */
	public GameView view;
	public int[] dimensions = new int[]{854,480};
	public boolean turned;
	public SensorManager manager;
	public Sensor accelerometer;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Display display = getWindowManager().getDefaultDisplay();
        dimensions[0] = display.getWidth();
        dimensions[1] = display.getHeight();
        if (dimensions[0]>dimensions[1]){
        	turned = true;
        }else{
        	turned = false;
        }
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        manager = (SensorManager)getSystemService(SENSOR_SERVICE);
        accelerometer = manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    }
    public void onResume(){
    	super.onResume();
    	manager.registerListener(this,accelerometer, SensorManager.SENSOR_DELAY_GAME);
    }
    public void onPause(){
    	super.onPause();
    	manager.unregisterListener(this);
    	finish();
    }
    public void flipOrientation(){
    	dimensions = new int[]{dimensions[1],dimensions[0]};
    }
	public void onAccuracyChanged(Sensor arg0, int arg1) {
		// TODO Auto-generated method stub
		
	}
	public void onSensorChanged(SensorEvent event) {
		if (view!=null){
		view.NewAccelerometerValues(event.values[0], event.values[1], event.values[2]);
		}
	}
}